part of '../../repository.dart';

const _kGooglePlayTransactionUserRevocationSourceValue = 'user';
const _kGooglePlayTransactionDeveloperRevocationSourceValue = 'developer';
const _kGooglePlayTransactionGoogleRevocationSourceValue = 'google';

class _GooglePlayTransactionRevocationSourceDto extends Equatable {
  const _GooglePlayTransactionRevocationSourceDto._internal({
    required this.sourceString,
  });

  final String sourceString;

  @override
  List<Object?> get props {
    return [
      sourceString,
    ];
  }

  factory _GooglePlayTransactionRevocationSourceDto.fromString(String sourceString) {
    return _GooglePlayTransactionRevocationSourceDto._internal(
      sourceString: sourceString,
    );
  }

  GooglePlayTransactionRevocationSource toEntity() {
    return switch (sourceString) {
      _kGooglePlayTransactionUserRevocationSourceValue =>
        GooglePlayTransactionRevocationSource.user,
      _kGooglePlayTransactionDeveloperRevocationSourceValue =>
        GooglePlayTransactionRevocationSource.developer,
      _kGooglePlayTransactionGoogleRevocationSourceValue =>
        GooglePlayTransactionRevocationSource.google,
      _ => throw UnimplementedError(),
    };
  }
}
